package TestMethod;

//带参有返回值
public class MethodDemo4 {

    //求n!的方法
    public int fac(int n){
        int sum=1;
        for (int i=1;i<=n;i++){
            sum=sum*i;
        }
        return sum;
    }
    public static void main(String[] args) {
        MethodDemo4 methodDemo4=new MethodDemo4();
        //求1!+2!+3!+4!+5!
        int sum=0;
        for (int i=1;i<=5;i++){
            sum=methodDemo4.fac(i)+sum;
        }
        System.out.println("1!+2!+3!+4!+5!的结果是:"+sum);

    }
}
